package com.gxa.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxa.domain.dto.ProductQueryDto;
import com.gxa.domain.entity.Product;
import com.gxa.domain.vo.ProductListVo;
import com.gxa.mapper.ProductMapper;
import com.gxa.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements ProductService {
    @Autowired
    private ProductMapper productMapper;
    @Override
    public Page<ProductListVo> findProductByQueryDto(ProductQueryDto productQueryDto) {
        Page page = new Page(productQueryDto.getPageNo(), productQueryDto.getPageSize());
        return getBaseMapper().findProductByQueryDto(page, productQueryDto);
    }

    @Override
    public int insertProduct(Product product) {
        return productMapper.insertProduct(product);
    }

    @Override
    public Product findProductById(Integer serialNo) {
        return productMapper.findProductById(serialNo);
    }

    @Override
    public int updateProduct(Product product) {
        return productMapper.updateProduct(product);
    }

    @Override
    public int deleteProductById(Integer serialNo) {
        return productMapper.deleteProductById(serialNo);
    }

}
